<?php

class autocomplete extends CI_Controller {

	function index()
	{
		$this->load->view('pages/nos_partenaires');
	}

	function suggestionsVille()
	{
		$this->load->model('ville');
                $term = $this->input->post('term',TRUE);

                if (strlen($term) < 3) break;

                $rows = $this->ville->GetAutocomplete(array('keyword' => $term));

                $json_array = array();
                foreach ($rows as $row)
                    array_push($json_array, $row->name);

            echo json_encode($json_array);
	}
        
        function suggestionsDepartement(){
            // Search term from jQuery
		$term = $this->input->post('term');

		// Do mysql query or what ever
		$arr = array($term, 'Ile de France', 'Essonne', 'Seine et Marne','Haut-de-Seine','Seine Saint denis','Oise','Yvelines','Bouche du Rhone');

		// Return data
		echo json_encode($arr);
        }
        
        function suggestionsEtablissement(){
            
        }
        
}

/* End of file autocomplete.php */
/* Location: ./application/controllers/autocomplete.php */
?>
